<template>
  <div>
    <el-table
      :data="tableData"
      :span-method="objectSpanMethod"
      border
      style="width: 100%; margin-top: 20px"
    >
      <el-table-column
        prop="id"
        label="ID"
        width="180"
      />
      <el-table-column
        label="姓名"
      >
        <template slot-scope="scope">
          <span>{{ scope.row.name.value }}</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="amount1"
        label="数值 1（元）"
      />
      <el-table-column
        prop="amount2"
        label="数值 2（元）"
      />
      <el-table-column
        prop="amount3"
        label="数值 3（元）"
      />
    </el-table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      tableData: [{
        id: '12987122',
        name: { value: '王小虎1', rowspan: 2 },
        amount1: '1',
        amount2: '2',
        amount3: 3
      }, {
        id: '12987123',
        name: { value: '王小虎2', rowspan: 0 },
        amount1: '1',
        amount2: '2',
        amount3: 3
      }, {
        id: '12987124',
        name: { value: '王小虎3', rowspan: 1 },
        amount1: '1',
        amount2: '2',
        amount3: 3
      }, {
        id: '12987125',
        name: { value: '王小虎4', rowspan: 3 },
        amount1: '1',
        amount2: '2',
        amount3: 3
      }, {
        id: '12987126',
        name: { value: '王小虎5', rowspan: 0 },
        amount1: '1',
        amount2: '2',
        amount3: 3
      }, {
        id: '12987126',
        name: { value: '王小虎6', rowspan: 0 },
        amount1: '1',
        amount2: '2',
        amount3: 3
      }]
    }
  },
  methods: {
    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      console.log(row, column, rowIndex, columnIndex)
      if (columnIndex === 1) {
        return {
          rowspan: row.name.rowspan,
          colspan: 1
        }
        // return {
        //   rowspan: 1,
        //   colspan: 1
        // }
      }
    }
  }
}
</script>
